<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>邀请好友</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body {
            background-color: #F8F8F8;
            font-size: 0.24rem;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: PingFangSC-Regular, sans-serif;
            color: #333333;
        }

        .outImg {
            width: 100%;
            height: auto;
            background: url("../../image/bghglhjx.png") no-repeat center;
            background-size: 100% 100%;
            box-sizing: border-box;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            position: relative;
            padding-bottom: 0.36rem;
        }

        .invitedBox {
            width: calc(100% - 0.5rem);
            background: url("../../image/bgyaoqingmax.png") no-repeat center;
            height: 1.9rem;
            padding: 0 0.22rem;
            border-radius: 0.04rem;
            box-sizing: border-box;
            margin-top: 2.25rem;
        }

        .scoendBgImg {
            width: 100%;
            height: auto;
            background-size: 100% 100%;
            position: absolute;
            top: 0.25rem;
            left: 0;
            display: flex;
            display: -webkit-flex;
            justify-content: center;
        }

        .p1 {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            color: #61080D;
            margin-top: 0.2rem;
        }

        .p1>span {
            display: flex;
            display: -webkit-flex;
            align-items: center;
            font-size: 0.24rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: #61080D;
        }

        .p1>.copy {
            color: rgba(203, 160, 126, 1);
        }

        .invitedAccount {
            height: 0.36rem;
            display: inline-block;
            border-radius: 1rem;
            padding: 0 0.16rem;
            text-align: center;
            background: #F4D992;
            color: #61080D;
            font-size: 0.2rem;
            margin-left: 0.13rem;
            line-height: 0.36rem;
        }

        .buttons {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            color: #ffffff;
            margin-top: 0.3rem;
        }

        .buttons span {
            height: 0.77rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
            background-size: 100% 100%;
        }

        .showCode {
            background: url("../../image/iconerweima.png") center center no-repeat;
            width: 1.98rem;
        }

        .invitedFs {
            background: url("../../image/iconyaoqing.png") center center no-repeat;
            width: 2.63rem;
        }

        .initProfit {
            background: url("../../image/iconhaibao.png") center center no-repeat;
            width: 2.03rem;
        }

        .content {
            width: 7rem;
            height: 6.25rem;
            background: url("../../image/newsdsgjk.png") no-repeat center;
            background-size: 100% 100%;
            position: relative;
            margin-top: 0.39rem;
        }

        .d1bottom {
            width: 6.57rem;
            height: 1.3rem;
            position: absolute;
            bottom: 0.1rem;
            background: url("../../image/nsnefdhj.png") no-repeat center;
            background-size: 100% 100%;
            left: calc((100% - 6.3rem) / 2);
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .d1bottom p {
            position: relative;
        }

        .d1bottom>.title>span:before {
            position: absolute;
            left: -0.6rem;
            bottom: 0.16rem;
            display: block;
            content: '';
            width: 0.32rem;
            height: 0.22rem;
            background: url(../../image/lefttcions.png) no-repeat;
            background-size: 100% 100%;
        }

        .d1bottom>.title>span:after {
            position: absolute;
            right: -0.6rem;
            bottom: 0.16rem;
            display: block;
            content: '';
            width: 0.32rem;
            height: 0.22rem;
            background: url(../../image/rightcions.png) no-repeat;
            background-size: 100% 100%;
        }

        .list {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-around;
        }

        .title {
            display: flex;
            display: -webkit-flex;
            justify-content: center;
            align-items: center;
            font-size: 0.32rem;
            font-weight: 500;
            color: rgba(104, 25, 24, 1);
        }

        .list div {
            display: flex;
            display: -webkit-flex;
            color: #61080D;
            align-items: center;
        }

        .list div p:last-of-type {
            margin-left: 0.1rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .list div p:last-of-type span {
            color: #F43601;
            font-size: 0.36rem;
            font-weight: bold;
            padding-bottom: 0.08rem;
        }

        .pageDown {
            width: 100%;
            height: auto;
            background: url("../../image/bgtwosdhx.png") no-repeat center;
            background-size: 100% 100%;
            box-sizing: border-box;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            position: relative;
            padding-bottom: 0.36rem;
        }

        .listHeader {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.24rem;
            box-sizing: border-box;
            margin-top: 0.2rem;
            margin-bottom: 0.17rem;
        }

        .bigTitle {
            font-size: 0.44rem;
            font-family: QingYuan;
            font-weight: 400;
            color: rgba(255, 229, 162, 1);
        }

        .bigTitle:before {
            content: '';
            display: block;
            position: absolute;
            top: 0;
            left: 0.24rem;
            width: 0.58rem;
            height: 0.08rem;
            background: #FFE5A2;
            border-radius: 0.05rem;
            z-index: 1;
        }

        .chooseData {
            flex: 1;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-end;
            font-size: 0.2rem;
            font-weight: 500;
            color: rgba(255, 255, 255, 0.44);
        }

        .chooseData span {
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .todayMonth {
            width: 1.8rem;
            margin: 0 0.3rem;
            font-size: 0.28rem;
            font-weight: 500;
            justify-content: center;
            color: rgba(255, 255, 255, 1);
        }

        .chooseData img {
            width: 0.12rem;
        }

        .rightImg {
            margin-left: 0.1rem;
        }

        .liftImg {
            margin-right: 0.1rem;
        }

        .tableImg {
            width: 7rem;
            height: 6.9rem;
            background: url("../../image/bgyaoqingtongjix.png") no-repeat center;
            background-size: 100% 100%;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
        }

        .orderNum {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-around;
            margin-top: 0.18rem;
            margin-bottom: 0.1rem;
        }

        .orderNum p {
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: rgba(104, 25, 24, 0.7);
        }

        .orderNum p span:last-of-type {
            margin-top: 0.1rem;
            font-size: 0.26rem;
            font-weight: 500;
            color: rgba(104, 25, 24, 1);
        }

        table {
            width: 6.7rem;
            max-height: 4.7rem;
            margin-left: 0.3rem;
        }

        thead {
            width: 100%;
            height: auto;
        }

        thead tr {
            width: 100%;
            height: 0.7rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
        }

        thead tr td {
            width: 25%;
            height: 0.7rem;
            text-align: center;
            line-height: 0.7rem;
            font-size: 0.22rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: rgba(104, 25, 24, 1);
        }

        thead tr td:last-of-type {
            padding-right: 0.1rem;
        }

        tbody {
            display: block;
            width: 100%;
            max-height: 3.9rem;
            overflow: scroll;
            box-sizing: border-box;
            -webkit-overflow-scrolling: touch;
        }

        tbody tr {
            width: 100%;
            height: 0.7rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
        }

        tbody tr td {
            width: 25%;
            height: 0.7rem;
            text-align: center;
            line-height: 0.7rem;
            font-size: 0.22rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: rgba(104, 25, 24, 1);
        }

        tbody tr td:first-of-type {
            padding-left: 0.25rem;
        }

        tbody tr td:last-of-type {
            padding-right: 0.25rem;
        }

        .statusButton {
            width: 6.1rem;
            height: 0.5rem;
            background: rgba(245, 220, 148, 1);
            border-radius: 0.04rem;
            text-align: center;
            line-height: 0.5rem;
            font-size: 0.22rem;
            font-weight: 500;
            color: rgba(104, 25, 24, 1);
            margin-left: calc((100% - 6.1rem) / 2);
            margin-bottom: 0.2rem;
        }

        .tipText {
            width: 6.1rem;
            font-size: 0.2rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: rgba(218, 3, 0, 1);
            text-align: center;
            margin-left: calc((100% - 6.1rem) / 2);
        }

        .btmimg {
            margin-top: 0.32rem;
        }

        .btmimg img {
            height: 0.35rem;
        }

        .fixedButton {
            width: 100%;
            height: 1.6rem;
            position: sticky;
            bottom: 0;
            left: 0;
            z-index: 100;
            background: rgba(255, 255, 255, 0.98);
            border-radius: 0.24rem 0.24rem 0px 0px;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
        }

        .lookPage {
            outline: none;
            border: none;
            width: 6.1rem;
            height: 0.92rem;
            background: url("../../image/iconlingqufgx.png") no-repeat center;
            background-size: 100% 100%;
        }

        .hideBoxNew {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            display: none;
            overflow-y: scroll;
        }

        .hideShareImg {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
            padding-bottom: 0.3rem;
        }

        .hideShareImg img {
            width: 100%;
        }

        #shareImgBox {
            width: 100%;
            height: 2rem;
            display: flex;
            display: -webkit-flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 0.47rem;
            background-color: #fff;
            font-size: 0.28rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(154, 154, 154, 1);
            box-sizing: border-box;
        }

        #shareImgBox div {
            width: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
        }

        #shareImgBox div img {
            width: 2.19rem;
        }

        #shareImgBox div b {
            color: rgba(154, 154, 154, 1);
            font-weight: normal;
            margin-top: 0.17rem;
        }
    </style>
</head>

<body>
    <div class="outImg">
        <div class="scoendBgImg">
            <img src="" id="showNewimg" style="width:6.97rem;height:1.76rem;display: none;border-radius: 0.06rem;"
                data-url="" data-title="">
        </div>
        <div class="invitedBox">
            <p class="p1">
                <span>
                    <span class="left">我的邀请码</span>
                    <span class="invitedAccount" data-invitecode="">--</span>
                </span>
                <span class="copy">
                    <img src="../../image/iconcopy.png" alt="copy" style="width: 0.22rem;margin-right: 0.1rem;">
                    <span>复制</span>
                </span>
            </p>
            <div class="buttons">
                <span class="showCode">我的二维码</span>
                <span class="invitedFs">邀请中国大陆好友</span>
                <span class="initProfit">生成邀请海报</span>
            </div>
        </div>
        <div class="content">
            <div class="d1bottom">
                <p class="title"><span>累计邀请</span></p>
                <div class="list">
                    <div>
                        <p>邀请注册</p>
                        <p><span class="peopleNumber">0</span> 人</p>
                    </div>
                    <div>
                        <p>好友下单</p>
                        <p><span class="peopleMon">0</span> 人</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="pageDown">
        <div class="listHeader">
            <p class="bigTitle bt2">
                邀请统计
            </p>
            <div class="chooseData">
                <span class="upMonth">
                    <img src="../../image/leftxbgc.png" class="liftImg" alt=""> 上个月
                </span>
                <span class="todayMonth">
                </span>
                <span class="nextMonth">
                    下个月<img src="../../image/rightx.png" class="rightImg" alt="">
                </span>
            </div>
        </div>
        <div class="tableImg">
            <div class="orderNum">
                <p>
                    <span>
                        当月BTC订单
                    </span>
                    <span class="thisMonthBtc">
                        -- CNY
                    </span>
                </p>
                <p>
                    <span>
                        当月IPFS订单
                    </span>
                    <span class="thisMonthIpfs">
                        -- CNY
                    </span>
                </p>
            </div>
            <table>
                <thead>
                    <tr>
                        <td>
                            注册时间
                        </td>
                        <td>
                            邀请好友
                        </td>
                        <td>
                            当月BTC订单
                        </td>
                        <td>
                            当月IPFS订单
                        </td>
                    </tr>
                </thead>
                <tbody class="insertTbody">

                </tbody>
            </table>
            <b class="listImg" style="display: none;">
                <img src="../../image/norecordx.png" alt=""
                    style="width: 0.88rem;margin-top: 1rem;margin-bottom: 1.8rem;">
            </b>
            <p class="statusButton" id="getMoreList">
                加载更多
            </p>
            <p class="tipText">
                *BTC订单包含新下单和续单订单
            </p>
        </div>
        <div class="btmimg">
            <img src="../../image/xclsjssf.png" alt="">
        </div>
    </div>
    <div class="hideBoxNew" style="opacity: 0;">
        <div class="hideShareImg" id="hideShareImg">
            <img src="" class="shargeImg">
            <div id="shareImgBox">
                <div>
                    <img class="renrenlogo" src="">
                    <b>
                        全球算力资产管理及交易平台
                    </b>
                </div>
                <p class="erweima">

                </p>
            </div>
        </div>
    </div>
    <div class="fixedButton">
        <button class="lookPage">

        </button>
    </div>
</body>
<script src="../../script/autosize.js"></script>
<script src="../../script/jquery_three_two_one.js"></script>
<script src="../../script/jqueryqrcodemin.js"></script>
<script src="../../script/html2canvas.js"></script>
<script src="../../script/htmlto_image.js"></script>
<script src="../../script/fastclick.js"></script>
<script src="../../script/dotmin.js"></script>
<script src="../../script/app.js"></script>
<script type="text/html" id="indent">
        {{~it:item:index}}
        <tr>
            <td>{{=item.create_time}}</td>
            <td>{{=item.phone}}</td>
            <td>{{=item.asset}} CNY</td>
            <td>{{=item.ipfs_amount}} CNY</td>
        </tr>
        {{~}}
    </script>
<script>
    apiready = function () {
        var app = new APP();
        var account = app.getAccount();
        var wapUrl = app.wapUrl; //warp地址
        var imgList = [];
        var is_display = "0";//0 表示不隐藏  1 表示隐藏
        var dataYear = new Date().getFullYear();//当前年份
        var dataMonth = Number(app.accAdd(new Date().getMonth(), 1)) < 10 ? ("0" + app.accAdd(new Date().getMonth(), 1)) : app.accAdd(new Date().getMonth(), 1);//当前月份
        $(".todayMonth").text(dataYear + " - " + dataMonth);
        var param = {
            debug: true,
            crashlog: true,
            period: 0,
            channel: app.ST,
            appKey: "c2ba5a5484d5b8f3a587bf66"
        };
        var appVersion = app.AV.split(".");
        if (Number(appVersion[0]) > 3 || (Number(appVersion[0]) == 3 && Number(appVersion[2]) > 14)) {
            var ajAnalytics = api.require('ajAnalytics');
            ajAnalytics.init(param, function (ret, err) {
                app.log(JSON.stringify(ret) + JSON.stringify(err));
            })
        }
        //防抖函数
        function debounce(fn, delay) {
            var timer;
            return function () {
                var context = this;
                var args = arguments;
                clearTimeout(timer);
                timer = setTimeout(function () {
                    fn.apply(context, args)
                }, delay)
            }
        };
        var curPage = 1;
        var totalPage = 0;
        var userConfig = {
            recommendTitle: "助力好友解锁云算力",
            recommendText: "您的好友送您一份价值1866元IPFS云算力待领取",
            recommendUrl: wapUrl + account.uid,
            recommendImg: "widget://image/shareicon.png"
        };
        var wxMd, qqMd, sinaMd;
        function getNum(curPage, isdown, is_display) {
            app.ajaxPro({
                url: "member/get-invite-lists",
                values: {
                    token: account.token,
                    page: curPage,
                    type: is_display,
                    month: dataMonth,
                    year: dataYear
                },
                openFlower: true
            }, function (ret) {
                app.stopRefresh();
                if (ret.code == 200) {
                    $(".invitedAccount").text(ret.data.invite_code).attr("data-invitecode", ret.data.invite_code);
                    totalPage = ret.data.lists.totalPage;
                    $(".peopleNumber").text(ret.data.lists.inviteNum);
                    $(".peopleMon").text(ret.data.lists.orderPeople);
                    if (ret.data.banner.pic && account.uid != "810") {
                        $("#showNewimg").show().attr("src", ret.data.banner.pic).attr("data-url", ret.data.banner.url).attr("data-title", ret.data.banner.title);
                    }
                    $(".thisMonthBtc").text(ret.data.lists.totalAsset + 'CNY');
                    $(".thisMonthIpfs").text(ret.data.lists.ipfs_total + "CNY");
                    ret.data.lists.invitationList.map(function (item) {
                        item.create_time = item.regTime.split(" ")[0];
                        item.time_creatper = item.operateTime ? item.operateTime.split(" ")[0] : "--";
                        item.retentionBonus = item.retentionBonus || 0;
                        item.commission_power = item.commissionPower || 0;
                        item.prizePower = item.prizePower || 0;
                    });
                    var temp = doT.template($("#indent").text());
                    if (isdown) {
                        $(".insertTbody").html(temp(ret.data.lists.invitationList));
                    } else {
                        $(".insertTbody").append(temp(ret.data.lists.invitationList));
                    }
                    if (ret.data.lists.invitationList.length == 0 && totalPage == 0) {
                        $("#getMoreList").hide();
                        $(".listImg").show();
                    }
                    if (ret.data.lists.invitationList.length == 0 && totalPage != 0) {
                        $("#getMoreList").show().text("没有更多了");
                    }
                }

            });
        }
        getNum(curPage, true, is_display);
        //计算日期
        function caluetMonth(year, month, type) {
            if (type == "add") {
                dataMonth = Number(app.accAdd(month, 1)) < 10 ? ("0" + app.accAdd(month, 1)) : app.accAdd(month, 1);
                if (Number(dataMonth) > 12) {
                    dataYear = app.accAdd(year, 1);
                    dataMonth = "01"
                }
                $(".todayMonth").text(dataYear + " - " + dataMonth);
            } else {
                dataMonth = Number(app.numSub(month, 1)) < 10 ? ("0" + app.numSub(month, 1)) : app.numSub(month, 1);
                if (Number(dataMonth) < 1) {
                    dataYear = app.numSub(year, 1);
                    dataMonth = "12"
                }
            }
            $(".todayMonth").text(dataYear + " - " + dataMonth);
            curPage = 1;
            totalPage = 0;
            $(".insertTbody").empty();
            getNum(curPage, true, is_display);
        };
        function clearTexts(params) {
            $(".peopleNumber,.peopleMon").text("");
            $(".insertTbody").empty();
        }
        $(".nextMonth").click(debounce(function () {
            var thisMonth = app.accAdd(new Date().getMonth(), 1);
            if (Number(dataMonth) >= Number(thisMonth)) return
            clearTexts();
            caluetMonth(dataYear, dataMonth, "add");
        }, 1000))
        $(".upMonth").click(debounce(function () {
            clearTexts();
            caluetMonth(dataYear, dataMonth, "dis");
        }, 1000))
        $(".copy").click(function () {
            if (app.clipboard) {
                var text = $(".invitedAccount").attr("data-invitecode");
                if (text) {
                    app.clipboard.set({
                        value: text
                    }, function (ret, err) {
                        app.log("copy", ret);
                        if (ret.status) {
                            app.toast("复制成功");
                        } else {
                            app.toast("复制失败");
                        }
                    });
                } else {
                    app.toast("复制不能为空");
                }
            }
        })
        //调用微信相关
        function share(index, imgPath) {
            var wxMd;
            switch (index) {
                case 0:
                    if (!wxMd) {
                        wxMd = api.require("wxPlus");
                    }
                    //检测是否装有微信
                    wxMd.isInstalled(function (r, e) {
                        if (r.installed) {
                            wxMd.shareImage({
                                scene: 'session',
                                contentUrl: imgPath
                            }, function (r, err) {
                                // console.log('分享err' + JSON.stringify(err))
                                if (r.status) {
                                    app.toast("分享成功");
                                } else {
                                    app.log("分享失败回错误码", e.code);
                                    if (err.code == 2) {
                                        app.toast("取消分享");
                                    } else {
                                        app.toast("分享失败");
                                    }
                                }
                            }
                            );
                        } else {
                            app.toast("当前设备未安装微信客户端");
                        }
                    });
                    break;
                case 1:
                    if (!wxMd) {
                        wxMd = api.require("wxPlus");
                    }
                    //检测是否装有微信
                    wxMd.isInstalled(function (r, e) {
                        if (r.installed) {
                            wxMd.shareImage({
                                scene: "timeline",
                                thumb: "widget://res/web/images/shareicon.png",
                                contentUrl: imgPath
                            }, function (r, err) {
                                if (r.status) {
                                    app.toast("分享成功");
                                } else {
                                    if (err.code == 2) {
                                        app.toast("取消分享");
                                    } else {
                                        app.toast("分享失败");
                                    }
                                }
                                if (err) {
                                    console.log("----------------" + JSON.stringify(err));
                                }
                            }
                            );
                        } else {
                            app.toast("当前设备未安装微信客户端");
                        }
                    });
                    break;
            }
        }
        //处理保存图片还是打开微信
        function shareOrDown(clickIndex, imgPath) {
            app.closeFlower();
            $(".hideBoxNew").hide();
            if (clickIndex == 2) {
                app.saveMediaToAlbum(imgPath);
            } else {
                share(clickIndex, imgPath);
            }
        }
        //微信邀请 大陆好友
        function showInvitedProfit(imgList) {
            var param = {
                dtype: "dialog76",
                imgs: imgList,
                stopPropagation: true
            };
            app.dialog(param);
        }
        //监听选择的retVal 是1微信 2.微信朋友圈 3. 保存相册 
        app.listen('shareProfit', function (ret) {
            $(".shargeImg").attr("src", '');
            $(".erweima").empty('');
            var retVal = ret.value;
            $(".erweima").qrcode({
                render: "canvas", //也可以替换为table
                width: 70,
                height: 70,
                text: wapUrl + account.uid
            });
            var imgUrl = imgList[retVal.imgIndex].address;
            app.remove("fs://newshargeimg/sharenewimg.png");
            app.downloadImg(imgUrl, 'sharenewimg', function (ret) {
                app.openFlower();
                var trans = api.require("trans");
                trans.decodeImgToBase64({
                    imgPath: "fs://newshargeimg/" + 'sharenewimg' + ".png"
                }, function (ret, err) {
                    if (ret.status) {
                        var str = ret.base64Str;
                        $(".hideBoxNew").show();
                        var imgsrc = "data:image/png;base64," + str;
                        $(".shargeImg").attr("src", imgsrc);
                        htmltoImage.init({
                            'el': document.getElementById("hideShareImg"),
                            'isImageObject': true,
                        }, function (res, err) {
                            if (res) {
                                var base64Str1 = htmltoImage.cutprefixBase64(res.base64str);
                                var imgName = retVal.index == 2 ? ("renren" + new Date().getTime() + ".png") : 'shareprofit.png'
                                trans.saveImage({
                                    base64Str: base64Str1,
                                    imgPath: "fs://posterimg/",
                                    imgName: imgName,
                                }, function (ret, err) {
                                    if (ret.status) {
                                        shareOrDown(retVal.index, "fs://posterimg/" + imgName);
                                    } else {
                                        app.toast("生成图片失败");
                                    }
                                });
                            } else {
                                app.toast("转换失败");
                            }
                        })
                    } else {
                        app.log("trans" + JSON.stringify(err));
                    }
                });
            })
        });
        $(".initProfit").click(function () {
            app.asynchronousAjax("site/stat", {
                type: 4
            }, function (ret) { })
            if (Number(appVersion[0]) > 3 || (Number(appVersion[0]) == 3 && Number(appVersion[2]) > 14)) {
                if (app.ST != "ios") {
                    ajAnalytics.onEvent({
                        eventType: "count",
                        eventId: 'initProfitanzhuo',
                        attrs: { "idNameinanzhuo": "initProfitanzhuo" }
                    }, function (ret, err) {
                        console.log(JSON.stringify(ret));
                    });
                }
                //自定义计数
                ajAnalytics.onEvent({
                    eventType: "count",
                    eventId: 'initProfit',
                    attrs: { "idNamein": "initProfit" }
                }, function (ret, err) {
                    console.log(JSON.stringify(ret));
                });
            }
            app.imgToTrans("widget://image/logonewsx.png", function (ret) {
                $(".renrenlogo").attr("src", "data:image/png;base64," + ret);
            })
            app.getPicJurisdiction(function (ret) {
                app.ajaxPro({
                    url: "site/get-poster-image",
                    values: {},
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        imgList = ret.data.lists;
                        showInvitedProfit(imgList);
                    }
                });
            })
        });
        $("#showNewimg").click(function () {
            if ($(this).attr("data-url").split("-")[0] == "nationalDay") {
                app.openWin({
                    name: "browser_header_win",
                    url: app.hd + "common/headerwin.html",
                    pageParam: {
                        subpage: $(this).attr("data-url").split("-")[1] + account.uid,
                        name: "browser_header_win",
                        type: "remote",
                        isremote: "true",
                        title: $(this).attr("data-title")
                    }
                });
                return
            }
            app.openWin({
                name: "rent_activity",
                url: app.hd + "common/headerwin.html",
                pageParam: {
                    subpage: $(this).attr("data-url") + account.uid + "&pageName=yaoqinghaoyou",
                    name: "rent_activity",
                    type: "remote",
                    isremote: "true",
                    title: $(this).attr("data-title") || "邀请好友活动"
                }
            });

        });
        $(".showCode").click(function () {
            app.asynchronousAjax("site/stat", {
                type: 2
            }, function (ret) { })
            if (Number(appVersion[0]) > 3 || (Number(appVersion[0]) == 3 && Number(appVersion[2]) > 14)) {
                if (app.ST != "ios") {
                    ajAnalytics.onEvent({
                        eventType: "count",
                        eventId: 'showCodeanzhuo',
                        attrs: { "idNameshanzhuo": "showCodeanzhuo" }
                    }, function (ret, err) {
                        console.log(JSON.stringify(ret));
                    });
                }
                //自定义计数
                ajAnalytics.onEvent({
                    eventType: "count",
                    eventId: 'showCode',
                    attrs: { "idNamesh": "showCode" }
                }, function (ret, err) {
                    console.log(JSON.stringify(ret));
                });
            }
            var param = {
                dtype: "dialog78",
                data: {
                    urlImg: wapUrl + account.uid,
                }
            };
            app.dialog(param);
        })
        $(".invitedFs").click(function (e) {
            app.asynchronousAjax("site/stat", {
                type: 3
            }, function (ret) { })
            if (Number(appVersion[0]) > 3 || (Number(appVersion[0]) == 3 && Number(appVersion[2]) > 14)) {
                if (app.ST != "ios") {
                    ajAnalytics.onEvent({
                        eventType: "count",
                        eventId: 'invitedFsanzhuo',
                        attrs: { "idNameinvanzhuo": "invitedFsanzhuo" }
                    }, function (ret, err) {
                        console.log(JSON.stringify(ret));
                    });
                }
                //自定义计数
                ajAnalytics.onEvent({
                    eventType: "count",
                    eventId: 'invitedFs',
                    attrs: { "idNameinv": "invitedFs" }
                }, function (ret, err) {
                    console.log(JSON.stringify(ret));
                });
            }
            var param = {
                dtype: "dialog9",
                data: {
                    title: "",
                    text: "",
                    btns: [{
                        name: "取消",
                        event: "cancel"
                    }],
                    lis: [{
                        name: "微信",
                        event: "click",
                        index: 0
                    },
                    {
                        name: "朋友圈",
                        event: "click",
                        index: 1
                    },
                    {
                        name: "QQ",
                        event: "click",
                        index: 2
                    },
                    {
                        name: "新浪微博",
                        event: "click",
                        index: 3
                    }
                    ],
                    extra: {}
                }
            };
            app.dialog(param);
            app.listen("click", function (ret, err) {
                var index = ret.value.index;
                app.log("click_index", index);
                switch (index) {
                    case 0:
                        if (!wxMd) {
                            wxMd = api.require("wxPlus");
                        }
                        //检测是否装有微信
                        wxMd.isInstalled(function (r, e) {
                            if (r.installed) {
                                wxMd.shareWebpage({
                                    scene: "session",
                                    title: userConfig.recommendTitle,
                                    description: userConfig.recommendText,
                                    thumb: userConfig.recommendImg,
                                    contentUrl: userConfig.recommendUrl
                                }, function (r, e) {
                                    if (r.status) {
                                        app.toast("分享成功");
                                    } else {
                                        app.toast("分享失败");
                                    }
                                });
                            } else {
                                app.toast("当前设备未安装微信客户端");
                            }
                        });
                        break;
                    case 1:
                        if (!wxMd) {
                            wxMd = api.require("wxPlus");
                        }
                        //检测是否装有微信
                        wxMd.isInstalled(function (r, e) {
                            if (r.installed) {
                                wxMd.shareWebpage({
                                    scene: "timeline",
                                    title: userConfig.recommendTitle,
                                    description: userConfig.recommendText,
                                    thumb: userConfig.recommendImg,
                                    contentUrl: userConfig.recommendUrl
                                }, function (r, e) {
                                    if (r.status) {
                                        app.toast("分享成功");
                                    } else {
                                        app.toast("分享失败");
                                    }
                                }
                                );
                            } else {
                                app.toast("当前设备未安装微信客户端");
                            }
                        });
                        break;
                    case 2:
                        if (!qqMd) {
                            qqMd = api.require("qq");
                        }
                        qqMd.installed(function (ret, err) {
                            if (ret.status) {
                                qqMd.shareNews({
                                    url: userConfig.recommendUrl,
                                    title: userConfig.recommendTitle,
                                    description: userConfig.recommendText,
                                    imgUrl: userConfig.recommendImg2,
                                    type: "QFriend"
                                }, function () {
                                    //android不支持回调
                                }
                                );
                            } else {
                                app.toast("当前设备未安装QQ");
                            }
                        });
                        break;
                    case 3:
                        if (!sinaMd) {
                            sinaMd = api.require("weibo");
                        }
                        sinaMd.shareWebPage({
                            title: userConfig.recommendTitle,
                            text: userConfig.recommendText,
                            thumb: userConfig.recommendImg,
                            contentUrl: userConfig.recommendUrl
                        },
                            function (r, e) {
                                if (r.status) {
                                    app.toast("分享成功");
                                } else {
                                    app.toast("分享失败");
                                }
                            }
                        );
                        break;
                }
            });
        })
        $("#getMoreList").click(function () {
            if (curPage < totalPage) {
                curPage++;
                getNum(curPage, false, is_display);
            } else {
                $("#getMoreList").text("没有更多了");
            }
        });
        $(".lookPage").click(function () {
            var cointypecontract = {
                name: "couponfriends",
                subpage: "mine/couponfriends",
                title: "邀请奖励",
                param: {
                    pageName: "couponfriends"
                }
            }
            app.setNavBarAttr(cointypecontract);
        })
        app.headerMap();
    }
</script>

</html>